﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Criterion;
using Thaire.Investment.Domains.Transaction;

namespace Thaire.Investment.Repository
{
    public class EquityHeaderRepo : BaseRepository<EquityHeader, int>
    {
        public EquityHeaderRepo(ISession session)
            : base(session)
        {
        }

        public List<EquityHeader> GetFullNameTH()
        {
            var projections = Projections.Distinct(Projections.ProjectionList()
                                  .Add(Projections.Property("FullNameTH").As("FullNameTH")));

            var result = new List<EquityHeader>(_session.QueryOver<EquityHeader>()
                                                    .Select(projections)
                                                    .TransformUsing(NHibernate.Transform.Transformers.AliasToBean<EquityHeader>())
                                                    .List());

            return result;
        }

        public List<EquityHeader> GetFullNameEN()
        {
            var projections = Projections.Distinct(Projections.ProjectionList()
                                  .Add(Projections.Property("FullNameEN").As("FullNameEN")));

            var result = new List<EquityHeader>(_session.QueryOver<EquityHeader>()
                                                    .Select(projections)
                                                    .TransformUsing(NHibernate.Transform.Transformers.AliasToBean<EquityHeader>())
                                                    .List());

            return result;
        }


    }
}
